package com.baidumap.administrator.happystudy.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.baidumap.administrator.happystudy.R;

import java.util.List;

/**
 * 描述：
 * 作者：xiaoxing on 17/4/8 17:52
 * 邮箱：2235445233@qq.com
 */
public class Adapter_GridView extends BaseAdapter {
    private Context mContext;

    private List<String> mMenuName;
    private List<Integer> mMenuImg;

    public Adapter_GridView(Context context, List<Integer> dataImg, List<String> dataName) {

        this.mContext = context;
        this.mMenuName = dataName;
        this.mMenuImg = dataImg;
    }

    @Override
    public int getCount() {
        return mMenuName.size();
    }

    @Override
    public Object getItem(int arg0) {
        return null;
    }

    @Override
    public long getItemId(int arg0) {
        return 0;
    }

    @Override
    public View getView(int position, View currentView, ViewGroup arg2) {
        HolderView holderView = null;
        if (currentView == null) {
            holderView = new HolderView();
            currentView = LayoutInflater.from(mContext).inflate(R.layout.adapter_grid_home, null);
            holderView.iv_pic = (ImageView) currentView.findViewById(R.id.iv_adapter_grid_pic);
            holderView.iv_name = (TextView) currentView.findViewById(R.id.iv_adapter_grid_name);
            currentView.setTag(holderView);
        } else {
            holderView = (HolderView) currentView.getTag();
        }


        holderView.iv_name.setText(mMenuName.get(position));
        holderView.iv_pic.setImageDrawable(mContext.getResources().getDrawable(mMenuImg.get(position)));
//         GlideUtil.displayImg(mContext, mMenuImg.get(position), holderView.iv_pic);
        return currentView;
    }


    public class HolderView {

        private ImageView iv_pic;
        private TextView iv_name;

    }

}
